<template>
<div>
  <b-card-header class="custom-info text-white font-weight-bold">game beginning</b-card-header>
  <b-card-body class="h-100">
<!--    调用GameForm组件，在子组件中完成选择的任务-->
    <GameForm @form-submitted="handleFormSubmitted"></GameForm>
  </b-card-body>
</div>
</template>
<!--首先渲染的菜单-->
<script>
import GameForm from '../components/GameForm'

export default {
  name: 'MainMenu',
  components: {
    GameForm
  },
  methods: {
    //接受GameForm的传入表单
    handleFormSubmitted(formData) {
      const query = formData
      query.difficulty = query.difficulty.toLowerCase()
      //获得传入表单后跳转到quiz拼接表单进入GameController组件
      //注意！！这里用name属性找到组件，并将表单传入
      this.$router.push({ name: 'quiz', query: query })
    }
  }
}
</script>

